﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;

namespace cMiller
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        bool running = false;

        public Thread runthread;
        public MainWindow()
        {
            InitializeComponent();
            runthread = new Thread(this.run);
            buttonlist.ItemsSource = sendKey.VirtualKeyStates;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            runthread = new Thread(this.run);
            runthread.Start();
        }

        private void run()
        {           
            while (true)
            {
                sendKey.ControlSendMessage("World of Warcraft", sendKey.VirtualKeyStates.VK_2, false);
                Thread.Sleep(500);
            }
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (runthread.IsAlive)
            {
                runthread.Suspend();
            }
        }
    }
}
